<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>发放专员查看自己的任务页面</title>
    <!--1.引入 bootstrap 框架全局样式 -->
    <link rel="stylesheet" href="../bootstrap/css/bootstrap.min.css"/>
    <!--2.引入 angularJS 分页的样式 -->
    <link rel="stylesheet" href="../angularjs/pagination.css">
    <!--3.引入 jquery 框架类库 -->
    <script src="../bootstrap/js/jquery.min.js"></script>
    <!--4.引入 bootstrap 框架类库 -->
    <script src="../bootstrap/js/bootstrap.min.js"></script>
    <!--5.引入 angularJS 框架类库 -->
    <script src="../angularjs/angular.min.js"></script>
    <!--6.引入 angularJS 框架分页的类库 -->
    <script src="../angularjs/pagination.js"></script>
    <!--7.引入layer css-->
    <link rel="stylesheet" href="https://www.layuicdn.com/layui/css/layui.css">
    <!--8.引入layer js-->
    <script src="https://www.layuicdn.com/layui/layui.js"></script>
    <script>
        var app = angular.module("taskApprovalApp", ['ngCookies', 'pagination']).config(function ($httpProvider) {
            $httpProvider.defaults.useXDomain = true;
            delete $httpProvider.defaults.headers
                .common['X-Requested-With']
        });
        app.controller("taskApprovalController", function ($scope, $http, $window, $cookieStore, $element) {
            //首先拿到token跟rname
            var token = $window.localStorage.getItem("tokens");
            $scope.rname = $window.localStorage.getItem("rname");
            $scope.task = {};

            //定义分页参数
            $scope.paginationConf = {
                //引入分页属性
                currentPage: 1,//当前页
                itemsPerPage: 4,//每页多少个
                totalItems: 100,//一共多少数据
                perPageOptions: [2, 5, 10, 20, 50, 100],//代表分页的选项
                onChange: function () {
                    $scope.getTask($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage)
                }
            };
            //跳转模糊查询
            $scope.getData = function () {
                $scope.getTask($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
            };

            $scope.getTask = function (index, size) {
                $scope.task.token = token;
                $http.post("http://localhost:10088/distribution/getMyCompletedTask?index=" + index + "&size=" + size,
                    $scope.task, {headers: {'auth': token}}).success(function (data) {

                    if (data.code === 200) {
                        $scope.lists = data.data.list;
                        $scope.paginationConf.totalItems = data.data.total;
                    } else {
                        // layer.msg(data.msg);
                    }
                });
            };

            //页面跳转
            $scope.toPage = function (url) {
                $window.location.href = url;
            };
            //退出登录
            $scope.logout = function () {
                $window.localStorage.setItem("tokens", "");
                $window.location.href = "../admin/login.html";
            }

        });

    </script>
</head>
<body ng-app="taskApprovalApp" ng-controller="taskApprovalController" ng-init="getData()">
<div class="navbar navbar-default">
    <div class="container-fluid">
        <div class="navbar-header">
            <a class="navbar-brand" href="#">工作人员后台</a>
        </div>
        <ul class="nav navbar-nav">
            <li class="active"><a href="javascript:void(0)" ng-click="toPage('index.html')">任务领取</a></li>
            <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                    我的任务<b class="caret"></b>
                </a>
                <ul class="dropdown-menu">
                    <li><a href="javascript:void(0)" ng-click="toPage('myCompletingTaskDistribution.html')">待完成任务</a></li>
                    <li><a href="javascript:void(0)" ng-click="toPage('myCompletedTaskDistribution.html')">已完成任务</a></li>
                </ul>
            </li>
        </ul>
        <ul class="nav navbar-nav navbar-right">
            <li><a href="#"><span class="glyphicon glyphicon-user"></span>角色: {{rname}}</a></li>
            <li><a href="javascript:void(0)" ng-click="logout()"><span class="glyphicon glyphicon-log-in"></span>注销</a>
            </li>
        </ul>

    </div>

</div>
<div class="container-fluid">
    <div class="panel panel-default">
        <div class="panel-heading" style="text-align: center">
            <h2>已完成任务列表</h2>
        </div>
        <div class="panel-body">
            <table class="table table-bordered table-striped table-hover text-center">
                <tr>
                    <td>序号</td>
                    <td>任务编号</td>
                    <td>贷款金额</td>
                    <td>申请人姓名</td>
                    <td>分期期数</td>
                    <td>业务经理审批结果</td>
                    <td>发放结果</td>
                </tr>
                <tr ng-repeat="c in lists">
                    <td>{{$index + 1}}</td>
                    <td>{{c.id}}</td>
                    <td>{{c.amount}}</td>
                    <td>{{c.name}}</td>
                    <td>{{c.num}}</td>
                    <td>{{c.status}}
                        <span ng-if="c.status==2">
                            审批通过
                        </span>
                    </td>
                    <td>
                        <span ng-if="c.loanStatus==0">
                            未放款
                        </span>
                        <span ng-if="c.loanStatus==1">
                            已放款
                        </span>
                    </td>

                </tr>
                <tr>
                    <td colspan="7">
                        <!--分页标签一行代码：-->
                        <tm-pagination conf="paginationConf"></tm-pagination>
                    </td>
                </tr>
            </table>
        </div>
    </div>
</div>
</body>
</html>